package com.eqdd.yiqidian.ui.discover.gonggao;

import android.databinding.DataBindingUtil;

import com.eqdd.yiqidian.R;
import com.eqdd.yiqidian.base.BaseActivity;
import com.eqdd.yiqidian.GonggaoInfoActivityCustom;
import com.eqdd.yiqidian.bean.rebuild.NoticeResultBean;
import com.eqdd.yiqidian.bean.rebuild.slimedit.SlimEditHintBean;
import com.eqdd.yiqidian.http.DialogCallBack;
import com.eqdd.yiqidian.http.HttpConfig;
import com.eqdd.yiqidian.http.HttpResult;
import com.eqdd.yiqidian.utils.DateUtil;
import com.eqdd.yiqidian.utils.ToastUtil;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

import android.view.View;

public class GonggaoInfoActivity extends BaseActivity {
    private GonggaoInfoActivityCustom dataBinding;
    private String noticeId;

    @Override
    public void initBinding() {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_gonggao_info);
        initTopTitleBar(View.VISIBLE, "公告");
    }

    @Override
    public void initData() {
        noticeId = getIntent().getStringExtra("noticeId");

    }

    @Override
    public void setView() {
        OkGo.<HttpResult<NoticeResultBean>>post(HttpConfig.BASE_URL + HttpConfig.NOTICE_INFO)
                .params("noticeId", noticeId)
                .execute(new DialogCallBack<HttpResult<NoticeResultBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpResult<NoticeResultBean>> response) {
                        HttpResult<NoticeResultBean> httpResult = response.body();
                        ToastUtil.showShort(httpResult.getMsg());
                        if (httpResult.getStatus() == 200) {
                            dataBinding.tvTitle.setText(httpResult.getItems().getNoticeName());
                            dataBinding.tvTime.setText(DateUtil.format(httpResult.getItems().getCreateTime()));
                            dataBinding.tvContent.setText("1231321\t\t\n\n\n\n\n\n\n\n\n\n\n1231231n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n1231231n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + httpResult.getItems().getNoticeContent());
                        }
                    }
                });
        dataBinding.getRoot().post(() -> {
            dataBinding.rlRoot.setMinimumHeight(dataBinding.viewMeasure.getHeight());

        });
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {

        }
    }
}
